<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-projectInfo-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">任务书下达时间：</label>
				<div class="col-sm-8">
					<input id="taskOrderTime" name="taskOrderTime" class="form-control" type="date">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目编号：</label>
				<div class="col-sm-8">
					<input id="projectId" name="projectId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目名称：</label>
				<div class="col-sm-8">
					<input id="projectName" name="projectName" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">项目经理：</label>
				<div class="col-sm-8">
					<input id="pmp" name="pmp" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">所属处室：</label>
				<div class="col-sm-8">
					<input id="department" name="department" class="form-control" type="text">
				</div>
			</div>



			<div class="form-group">
				<label class="col-sm-3 control-label">开始时间：</label>
				<div class="col-sm-8 form-inline select-time">
					<input type="text" class="time-input form-control" id="startTime" placeholder="开始时间" name="startTime"/>
					<span class="form-control text-center" style="border:0;">结束时间</span>
					<input type="text" class="time-input form-control" id="endTime" placeholder="结束时间" name="endTime"/>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">预算下达情况：</label>
				<div class="col-sm-8">
					<select id="budgetStatus" class="form-control m-b" th:with="type=${@dict.getType('budget_status')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">项目状态：</label>
				<div class="col-sm-8">
					<select id="projectStatus" class="form-control m-b" th:with="type=${@dict.getType('project_status')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">订单下达状态：</label>
				<div class="col-sm-8">
					<input id="orderStatus" name="orderStatus" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">项目类型：</label>
				<div class="col-sm-8">
					<select id="projectType" class="form-control m-b" th:with="type=${@dict.getType('project_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/projectInfo"
		$("#form-projectInfo-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

		function submitHandler() {
			if ($.validate.form()) {
				//$.operate.save(prefix + "/edit", $('#form-baseInfo-edit').serialize());
				add();
			}
		}

		function add() {
			var taskOrderTime = $("input[name='taskOrderTime']").val();
			var projectId = $("input[name='projectId']").val();
			var projectName = $("input[name='projectName']").val();

			var pmp = $("input[name='pmp']").val();
			var department = $("input[name='department']").val();

			var startTime = $("#startTime").val();
			var endTime = $("#endTime").val();
			var budgetStatus = $("#budgetStatus option:selected").val();
			var projectStatus = $("#projectStatus option:selected").val();
			var orderStatus = $("input[name='orderStatus']").val();
			var projectType = $("#projectType option:selected").val();
			var remark = $("input[name='remark']").val();
			$.ajax({
				cache : true,
				type : "POST",
				url : ctx + "pm/projectInfo/add",
				data : {
					"taskOrderTime":taskOrderTime,
					"projectId":projectId,
					"projectName":projectName,
					"pmp": pmp,
					"department": department,
					"startTime":startTime,
					"endTime":endTime,
					"budgetStatus":budgetStatus,
					"projectStatus":projectStatus,
					"orderStatus":orderStatus,
					"projectType":projectType,
					"remark":remark
				},
				async : true,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					$.operate.saveSuccess(data);
				}
			});
		}

		$(function(){
			var time = new Date()
			var day = ('0' + time.getDate()).slice(-2)
			var month = ('0' + (time.getMonth() + 1)).slice(-2)
			var today = time.getFullYear() + '-' + month + '-' + day
			$('#taskOrderTime').val(today)
		})
	</script>
</body>
</html>
